package com.shine.sys.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shine.common.web.controller.BaseController;
import com.shine.common.web.validate.AjaxResponse;
import com.shine.sys.entity.RoleResource;
import com.shine.sys.service.RoleResourceService;

@Controller
@RequestMapping("/admin/sys/role_resource")
public class RoleResourceController extends BaseController {

	@Autowired
	private RoleResourceService roleResourceService ;
	
	@RequestMapping(value="/add", method=RequestMethod.POST)
	@ResponseBody
	public AjaxResponse add(RoleResource entity) {
		this.roleResourceService.save(entity) ;
		return new AjaxResponse() ;
	}
	
	@RequestMapping(value="/get/{roleId}", method=RequestMethod.GET)
	@ResponseBody
	public RoleResource get(@PathVariable Integer roleId, Model model) {
		return this.roleResourceService.getOneByRoleId(roleId) ;
	}
	
}
